package com.cheng.im.gateway.protobuilder;

import com.cheng.im.common.bean.msg.ProtoMsgV1;
import org.springframework.stereotype.Service;

@Service("ChatMsgBuilder")
public class ChatMsgBuilder {

    public ProtoMsgV1.Message syncChatMsg(ProtoMsgV1.Message sourceMsg, String fromId) {
        ProtoMsgV1.Message.Builder mb = ProtoMsgV1.Message.newBuilder(sourceMsg);

        ProtoMsgV1.MessageRequest.Builder rb =
                ProtoMsgV1.MessageRequest.newBuilder(sourceMsg.getMessageRequest()).setTo(fromId);

        mb.setMessageRequest(rb);
        return mb.build();
    }

    public ProtoMsgV1.Message chatMsg(ProtoMsgV1.Message sourceMsg, String sessionId) {
        ProtoMsgV1.Message.Builder mb = ProtoMsgV1.Message.newBuilder(sourceMsg)
                .setSessionId(sessionId);
        return mb.build();
    }
}
